package com.example.demo.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        Stream<String> s2 = Stream.of("test", "t1", "t2", "teeeee", "aaaa");
        s2.map(n -> n.concat(".txt")).forEach(System.out::println);


        System.out.println(Stream.of(1, 2, 3).parallel().reduce(4, new BiFunction<Integer, Integer, Integer>() {
                    @Override
                    public Integer apply(Integer integer, Integer integer2) {
                        return integer + integer2;
                    }
                }
                , new BinaryOperator<Integer>() {
                    @Override
                    public Integer apply(Integer integer, Integer integer2) {
                        return integer + integer2;
                    }
                }));


        Stream<String> s1 = Stream.of("aa", "ab", "c", "ad");
        Predicate<String> predicate = t -> t.contains("a");
        System.out.println(s1.parallel().collect(() -> new ArrayList<String>(),
                (array, s) -> {if (predicate.test(s)) {array.add(s); }},
                (array1, array2) -> array1.addAll(array2)));



    }
}
